<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once("../../globals.php");
require_once("$srcdir/patient.inc");
require_once("$srcdir/acl.inc");
require_once("$srcdir/classes/Address.class.php");
require_once("$srcdir/classes/InsuranceCompany.class.php");
require_once("$srcdir/classes/Document.class.php");
require_once("$srcdir/options.inc.php");
require_once("../history/history.inc.php");
require_once("$srcdir/formatting.inc.php");
require_once("$srcdir/edi.inc");
require_once("$srcdir/clinical_rules.php");
include_once("$srcdir/lists.inc");
include_once("$srcdir/formdata.inc.php");
require_once("$srcdir/patient_provider.inc.php");
$values = $_REQUEST;

if( $values['action'] == 'close_old' ){
    $provider_id = $_SESSION['authUserID'];
    $query = " SELECT * " .
             "FROM form_encounter " .
             " WHERE provider_id = $provider_id AND ";
    $current_encounter = $_SESSION['encounter'];
    if( $current_encounter > 0 ){
        echo 'true';
    }else{
        echo 'false';
    }
}

else if( $values['type'] == '2' ){
    $current_encounter = $_SESSION['encounter'];
    if( $current_encounter > 0 ){
        $query = " SELECT * " .
            " FROM form_encounter " .
            " WHERE  =  " . $_SESSION['encounter'];
        $result = sqlStatement($query);
        $row = sqlFetchArray($result);
        if( $row['closed']=='0' ){
            echo '0';
        }else{
            echo '1';
        }
    }else{
        echo 'false';
    }
    
}

